<?php 
$user=$session->read('User');
$companyid=$session->read("companyid");
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
    	<h2>
		<?php 
		$companyname=$session->read("companyname");
		echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
		?>
    	</h2>
    	<div class='clear'></div>
    </div>
    <div class="right item_add_btn">
		<?php 
			$cuser=$session->read('User');
			if($form->value('CompOtherdeclare.id')){
			$str_title=__("Edit",true);
			}else{
			$str_title=__("Add",true);
			}
    		echo $html->link(__("Cancel",true).$str_title,"/companys/otherdeclare/");
    	?>
	</div>
    <div class="clear"></div>
</div>

<div class="right_side_scollbar">
	<div class="detail_info_panel">
	<?php echo $form->create('Company', array('url' => "/companys/editotherdeclare",'id'=>'otherform','enctype'=>'multipart/form-data','onsubmit'=>"return checksave()"));?>
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left"><font style="color:red">*</font>项目名称：</div>
			    <div class="form_right_e_input left">
			    	<?php echo $form->text('CompOtherdeclare.name',array("maxlength"=>"100","style"=>"width:147px"));?>
			    </div>
			    <div id='namemsg' style='display:none;' class="error_message">请填写项目名称</div>
			</div>
		</div>
	
		<!--
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left">主管部门：</div>
			    <div class="form_right_e_input left">
			    <?php 
			    	//$selectotrdecltype=$form->value("CompOtherdeclare.department"); 
			    	//echo $form->select('CompOtherdeclare.department',$otrdecltype, $selectotrdecltype, null,null);
			    ?>			    
			    </div>
			</div>
		</div>	
		-->
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left">级别：</div>
			    <div class="form_right_e_input left">
			    	<?php echo $form->text('CompOtherdeclare.level',array("maxlength"=>"100","style"=>"width:147px"));?>
			    </div>
			</div>
			<div class="details_item">
			    <div class="form_left_title left">部门：</div>
			    <div class="form_right_e_input left">
			    	<?php echo $form->text('CompOtherdeclare.branch',array("maxlength"=>"100","style"=>"width:147px"));?>
			    </div>
			</div>
			<div class="details_item">
			    <div class="form_left_title left"><font style="color:red">*</font>资助金额：</div>
			    <div class="form_right_e_input left">
			    <?php echo $form->text('CompOtherdeclare.fund',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> 万元 
			    </div>
			    <div id='fundmsg' style='display:none;' class="error_message">请填写资助金额</div>
			</div>
		</div>
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left">申报类型：</div>
			    <div class="form_right_e_input left">
			    	<?php echo $form->text('CompOtherdeclare.type',array("maxlength"=>"100","style"=>"width:147px"));?>
			    </div>
			</div>
			<div class="details_item">
			    <div class="form_left_title left">申报状态：</div>
			   	<div class="form_right_e_input left">
			    	<?php 
			    		$selectstatus = $form->value("CompOtherdeclare.status");
			    		echo $form->select('CompOtherdeclare.status',$dstatus,$selectstatus,null,null,null)
		    		?>
			    </div>
			</div>
		</div>
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left">申报时间：</div>
			    <div class="form_right_e_input form_date_picker left">
			    	<?php echo $form->text('CompOtherdeclare.declare_time',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?>
			    </div>
			</div>
			<div class="details_item">
			    <div class="form_left_title left">立项时间：</div>
			    <div class="form_right_e_input form_date_picker left">
			    	<?php echo $form->text('CompOtherdeclare.project_time',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?>
			    </div>
			</div>
			<div class="details_item">
			    <div class="form_left_title left">考核时间：</div>
			    <div class="form_right_e_input form_date_picker left">
			    	<?php echo $form->text('CompOtherdeclare.assessment_time',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?>
			    </div>
			</div>
		</div>
		<?php 
		if(!empty($filetypes)){
		$i = 0;
		foreach($filetypes as $key=>$ftype){
			$i++;
			if(($i%2) == 1){
				echo "<div class='details_item_line'><div class='details_item'>";
			}else{
				echo "<div class='details_item'>"; 
			}
		?>
		    <div class="form_left_title left"><?php echo $ftype?>：</div>
		    <div class="form_right_input left">
		    <?php 
        	 	$fildisplay="none";
    	 		if(!empty($attachments)){
					foreach($attachments as $attachment) {
						if($key==$attachment["cvid"]){
							$fildisplay="block";
						}
					}
				}
			 ?>
	            <div class="file_category_list" style="display:<?php echo $fildisplay?>">
	        		<div id="filelist<?php echo $key?>" class="file_lists">
	        			<ul class="file_attach">
		                	<?php
		                	$dan="'";
		                	if($attachments){
			                	foreach($attachments as $attachment) {
			                			if($key==$attachment["cvid"]){
											echo "<li>";
											echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
											echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
											if($action->checkPermissions($user,$companyid)){
												echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.','.$dan.$key.$dan.')" href="javascript:void(0)"></a></span>';
											}
											echo "</li>";
										}
								}
							}
		                	?>
		                </ul>
	                </div>
	            </div>
		    <div class="left text_box"> 
				<div class="file_add_box">
					<input type="file" id="upload[]" name="upload<?php echo $key?>[]" />
				</div>
			</div>
			<div class="clear"></div>
			<div id="declarefile<?php echo $key?>" class="left filelist"></div>
			<div class="left clear">
				<div class="left add_sub_file_btn">
					<span onclick="add('<?php echo $key?>')" href="#"><?php echo $html->image('list-add.png')?></span>&nbsp;
					<span onclick="remove('<?php echo $key?>')" href="#"><?php echo $html->image('list-remove.png')?></span>
				</div>
			</div>
		 </div>
		<?php
			if(($i%2) == 1){
				echo "</div>";
			}else{
				echo "</div></div>";
			}
		 }		 
		 echo "</div>";
		 }
		?>
	
        <div class="details_item_line">
            <div class="details_item">
            	<div class="form_left_title left"></div>
                <div class="form_add_submit left">
	                <?php echo $form->submit(__('Save',true), array("div"=>false)) ?>
	                <?php  echo $form->hidden('CompOtherdeclare.id'); ?>
	                <?php echo $form->hidden('CompOtherdeclare.cid',array("value"=>$companyid)) ;?>
			    	<?php echo $form->hidden('CompOtherdeclare.creater') ;?>
                </div>
            </div>
        </div>
	</div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
//$("#CompTalentDeclarateType option:first").html('请选择状态');
//$("#CompTalentName option:first").html('请选择名称');
function checksave(){
//	var typeid="";
//	var tid2=$("#selecttwo").find("select").val();
//	var tid1=$("#selectone").find("select").val();
//	if($("#selecttwo").html()!="" && tid2!=null && tid2!=""){
//		typeid=tid2;
//	}
//	else if($("#selectone").html()!="" && tid1!=null && tid1!=""){
//		typeid=tid1;
//	}
//	else if($("#CompanyTalmenu").val()!=""){
//		typeid=$("#CompanyTalmenu").val();
//	}
//	$("#CompTalentTypeId").val(typeid);
	
	
	if($("#CompOtherdeclareName").val().trim() == ''){
		$("#namemsg").css('display','block');
		return false;
	}else{
		$("#namemsg").css('display','none');
	}
	if($("#CompOtherdeclareFund").val().trim() == ''){
		$("#fundmsg").css('display','block');
		return false;
	}else{
		$("#fundmsg").css('display','none');
	}
	
}
//添加附件控件
function add(id) {
	var thenew= document.createElement('div');
	thenew.innerHTML ="<div class='file_add_box'><input type='file' id='upload[]' name='upload"+id+"[]'/></div>";
	document.getElementById("declarefile"+id).appendChild(thenew);
	$("#declarefile"+id+" :file").uniform();
	return false;
}
//删除附件控件
function remove(id) {
	var child=document.getElementById("declarefile"+id).lastChild;
	if(child){
		document.getElementById("declarefile"+id).removeChild(child);
	}
	return false;
}	
</script>